package main.Baskets;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import main.BaseServlet;
import main.Basket;
import main.Item;

@SuppressWarnings("serial")
public class DelFromBasket extends BaseServlet
{
	@Override
	protected void action(HttpServletRequest req, HttpServletResponse resp)
			throws IOException, ServletException
	{
		Basket bskt = (Basket) req.getSession().getAttribute("basket");
		try
		{
			Long id = Long.parseLong(req.getParameter("id").toString());
			Boolean boo = true;
			for (int i = 0; i < bskt.UserBasket.size() && boo; i++)
			{
				Item itm = bskt.UserBasket.get(i);
				if (itm.getGame().getId() == id)
				{
					bskt.UserBasket.remove(i);
					boo = false;
				}
			}
		} catch (Exception ex)
		{
		}
	}
}
